package top.oyyf.call_back_demo.controller;


import org.springframework.web.bind.annotation.*;
import top.oyyf.call_back_demo.service.CallbackService;

/**
 * 回调服务控制层
 */
@RestController
public class CallBackController {

    private final CallbackService callbackService;
    public CallBackController(CallbackService callbackService) {
        this.callbackService = callbackService;
    }

    /**
     * 回调接口，由企业微信调用请开放
     * 注意：
     * echoStr，get
     * xml
     * @param msgSignature  企业微信加密签名
     * @param timestamp     时间戳
     * @param nonce         随机数
     * @param echoStr       加密字符
     * @param xml           加密文档
     */
    @RequestMapping("/callback")
    public String callback(@RequestParam(value = "msg_signature", required = false) String msgSignature,
                                @RequestParam(value = "timestamp", required = false) String timestamp,
                                @RequestParam(value = "nonce", required = false) String nonce,
                                @RequestParam(value = "echostr", required = false) String echoStr,
                                @RequestBody(required = false) String xml)
    {
        return callbackService.callback(msgSignature,timestamp,nonce,echoStr,xml);
    }


}
